//
//  XMOperation.m
//  NSOperation操作依赖和监听
//
//  Created by 李煜 on 2024/4/23.
//

#import "XMOperation.h"

@implementation XMOperation

- (void)main {
	for (int i = 0; i < 10000; i++) {
		//官方不建议将判断放在耗时任务内,虽然精确取消,但是每次都要判断,很耗性能,建议放到耗时任务外
		//if (self.isCancelled){/*......*/ }
		NSLog(@"--down1--%d-%@",i,[NSThread currentThread]);
		
	}
	//********建议放到此处************
	
	//如果取消则不执行后续耗时任务
	if (self.isCancelled)return;
	
	NSLog(@"+++++++++++");
	for (int i = 0; i < 10000; i++) {
		NSLog(@"--down2--%d-%@",i,[NSThread currentThread]);
		
	}
	
	
	if (self.isCancelled)return;
	
	NSLog(@"+++++++++++");
	for (int i = 0; i < 10000; i++) {
		NSLog(@"--down3--%d-%@",i,[NSThread currentThread]);
		
	}


}
@end
